//
//  ProjectMainTableViewCell.swift
//  XMGG
//
//  Created by iDev on 6/25/17.
//  Copyright © 2017 iDev. All rights reserved.
//

import UIKit

class MainProjectTableViewCell: UITableViewCell {

    let pjNameLable = UILabel()
    let pjTimeLable = UILabel()
    let pjStatusLable = UILabel()
    let pjMemberLable = UILabel()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupCell()
    }
    
    private func setupCell(){
        addSubview(pjNameLable)
        addSubview(pjTimeLable)
        addSubview(pjStatusLable)
        addSubview(pjMemberLable)
        
        pjNameLable.textColor = UIColor(red: 17/255.0, green: 17/255.0, blue: 17/255.0, alpha: 1)
//        pjStatusLable.textColor = UIColor(red: 135/255.0, green: 137/255.0, blue: 137/255.0, alpha: 1)
        pjTimeLable.textColor = UIColor(red: 56/255.0, green: 124/255.0, blue: 124/255.0, alpha: 1)
        pjMemberLable.textColor = UIColor(red: 135/255.0, green: 137/255.0, blue: 137/255.0, alpha: 1)
        
//        pjNameLable.font = UIFont.systemFont(ofSize: 30*0.75)
//        pjStatusLable.font = UIFont.systemFont(ofSize: 28*0.75)
//        pjTimeLable.font = UIFont.systemFont(ofSize: 22*0.75)
//        pjMemberLable.font = UIFont.systemFont(ofSize: 28*0.75)
 
        pjNameLable.font = UIFont.init(name: "PingFang SC", size: 24*0.75)
        pjStatusLable.font = UIFont.init(name: "PingFang SC", size: 21.5*0.75)
        pjTimeLable.font = UIFont.init(name: "PingFang SC", size: 15*0.75)
        pjMemberLable.font = UIFont.init(name: "PingFang SC", size: 21.5*0.75)
        
        pjNameLable.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(25)
            make.top.equalToSuperview().offset(15)
        }
        pjStatusLable.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-40)
            make.top.equalTo(pjNameLable)
        }
        pjTimeLable.snp.makeConstraints { (make) in
            make.left.equalTo(pjNameLable)
            make.top.equalTo(pjNameLable.snp.bottom).offset(15)
        }
        pjMemberLable.snp.makeConstraints { (make) in
            make.left.equalTo(pjTimeLable.snp.right).offset(10)
            make.centerY.equalTo(pjTimeLable)
        }
    }
    
    func setCellTitle(modle:MainProjectModle){
        pjNameLable.text = modle.PJName
        pjTimeLable.text = modle.PJTime
        
        var memberStr = ""
        for member in modle.PJMembers{
            memberStr += member
            memberStr += " "
        }
        pjMemberLable.text = memberStr
        switch modle.PJState {
        case 0:
            pjStatusLable.text = "未完成"
            pjStatusLable.textColor = pjMemberLable.textColor
        case 1:
            pjStatusLable.text = "完成"
            pjStatusLable.textColor = pjTimeLable.textColor
        default:
            break
        }
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

}
